﻿using Coldairarrow.Business.A;
using Coldairarrow.Entity.A;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.A
{
    [Route("/A/[controller]/[action]")]
    public class A_TestShardingController : BaseApiController
    {
        #region DI

        public A_TestShardingController(IA_TestShardingBusiness a_TestShardingBus)
        {
            _a_TestShardingBus = a_TestShardingBus;
        }

        IA_TestShardingBusiness _a_TestShardingBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<A_TestSharding>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _a_TestShardingBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<A_TestSharding> GetTheData(IdInputDTO input)
        {
            return await _a_TestShardingBus.GetTheDataAsync(input.id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(A_TestSharding data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _a_TestShardingBus.AddDataAsync(data);
            }
            else
            {
                await _a_TestShardingBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _a_TestShardingBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}